package logic

import (
	"api/pkg"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type RealNameLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRealNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RealNameLogic {
	return &RealNameLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RealNameLogic) RealName(req *types.RealNameRequest) (resp *types.Response, err error) {
	if !pkg.RealName(req.RealName, req.IdCard) {
		return &types.Response{
			Code: -1,
			Msg:  "实名认证失败",
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 0,
		Msg:  "实名认证成功",
		Data: nil,
	}, nil
}
